<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\FhSetting;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class FhSettingController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new FhSetting(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('web_name');
            $grid->column('web_logo')->image();
            $grid->column('web_url');
            $grid->column('web_phone');
            $grid->column('web_keyword');
            $grid->column('web_desc');
            $grid->column('web_email');
            $grid->column('web_addr');
            $grid->column('web_qrcode');
            $grid->column('web_copyright');
            $grid->column('web_beian');
            $grid->actions(function ($actions) {
                // 隐藏显示按钮
                $actions->disableView();
                $actions->disableDelete();
            });
            $grid->disableCreateButton();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new FhSetting(), function (Show $show) {
            $show->field('id');
            $show->field('web_name');
            $show->field('web_logo');
            $show->field('web_url');
            $show->field('web_phone');
            $show->field('web_keyword');
            $show->field('web_desc');
            $show->field('web_email');
            $show->field('web_addr');
            $show->field('web_qrcode');
            $show->field('web_copyright');
            $show->field('web_beian');
            $show->field('web_link');
            $show->field('web_js');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new FhSetting(), function (Form $form) {
            $form->display('id');
            $form->text('web_name')->required();
            $form->image('web_logo')->required();
            $form->url('web_url')->required();
            $form->text('web_phone');
            $form->text('web_keyword')->required();
            $form->text('web_desc')->required();
            // $form->textarea('web_about','关于我们')->required();
            // $form->image('web_img','关于我们图片')->required();
            // $form->number('web_people','员工数量')->required();
            // $form->number('web_num','专利数量')->required();
            // $form->number('web_company','客户数量')->required();
            $form->number('index_num','首页新闻展示数量')->required();
            $form->text('app_title','首页应用标题')->required();
            $form->text('app_desc','首页应用描述')->required();
            $form->image('app_bg','首页应用背景图')->move('images/'.date("Ymd",time()))->dimensions(['min_width' => 1918, 'min_heigth' => 692])->help("最小分辨率 1918 * 692")->required();
            $form->email('web_email');
            $form->text('web_qq','QQ');
            $form->text('web_wechat','微信号');
            $form->text('web_skype','Skype');
            $form->text('web_addr');
            $form->image('web_qrcode');
            $form->text('web_copyright');
            $form->text('web_beian');
            $form->textarea('web_link')->help("使用,号隔开")->placeholder("例如<a href='http://www.baidu.com'>链接1</a>,<a href='http://www.baidu.com'>链接2</a>");
            $form->textarea('web_js');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
